//public class Test4 {
//    public static void main(String[] args) {
//        try {
//            Class loadClass = Class.forName("java.lang.Object");
//        }
//        catch (ClassNotFoundException e) {
////            throw new RuntimeException("ClassNotFoundException"); OK 将编译时异常转化为运行时异常
//            e.printStackTrace(); // OK 直接处理异常
//        }
//    }
//}

//public class Test4 {
//    public Test4 method() {
//        return new Test4();
//    }
//}
//
//class Test44 extends Test4 {
//    @Override
//    public Test44 method() {
//        return new Test44();
//    }
//
//    public static void main(String[] args) {
//        Test4 test4 = new Test44().method();
//    }
//}

//import java.io.IOException;
//
//class Father {
//    public void method() throws Exception {
//        System.out.println("Father.method");
//    }
//}
//
//class Son extends Father {
//    @Override
//    public void method() throws IOException, ClassCastException {
//        System.out.println("Son.method");
//    }
//}

//class Father {
//    public void method() {}
//}
//
//class Son extends Father {
//    @Override
//    public void method() throws RuntimeException {
//        throw new RuntimeException();
//    }
//}

public class Test4 {
    public static void main(String[] args) {
        try {
            System.out.println(max(4, 2, 31, 1));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            System.out.println(max(4));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            System.out.println(max());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static int max(int... nums) {
        if (nums == null || nums.length == 0) {
            throw new IllegalArgumentException("没有传入任何整数，无法获取最大值");
        }
        int max = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
            }
        }
        return max;
    }
}

//    private static void show(int... args) {
//        System.out.println(args.getClass().getName());
//    }
//
//    @Test
//    public void test() {
//        show(1, 2, 3, 4, 5);
//    }